package com.tfswx.jcyw.sqlmodel.api.bean.table;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author 张述江
 * @date 2023/9/15
 */
@Data
public class Alias implements Serializable {

    private String name;
    private boolean useAs = true;

    public Alias(String name, boolean useAs) {
        this.name = name;
        this.useAs = useAs;
    }

    public Alias(String name) {
        this(name, true);
    }

    public Alias() {
        this(null);
    }

    @Override
    public String toString() {
        if (StringUtils.isBlank(name)) {
            return "";
        }
        return (useAs ? " AS " : " ") + name;
    }
}
